using ASP;
using HoWave.Common;
using HoWave.Web;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
public class Go : HoWave_Root, IRequiresSessionState
{
	protected int UID;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.UID = Fetch.GetID("uid");
		if (this.UID == 0)
		{
			base.Response.Redirect("/", true);
		}
		string userIp = Fetch.UserIp;
		string referrer = Fetch.Referrer;
		string value = Fetch.Get("comeurl");
		string str = Fetch.Get("sign");
		string cstr = Text.Md5(userIp + "_DflWfd_" + this.UID);
		if (!Text.CheckMd5Text(str, cstr))
		{
			base.Response.Redirect("/?err=2", true);
		}
		if (base.Request.Cookies["itnet"] == null)
		{
			base.Response.Redirect("/?err=3", true);
		}
		if (!Text.CheckMd5Text(base.Request.Cookies["itnet"].Value, cstr))
		{
			base.Response.Redirect("/?err=4", true);
		}
		DataTable dataTable = this.conn.GetDataTable("Select * From [HL_User] Where UserID=" + this.UID);
		if (dataTable.Rows.Count <= 0)
		{
			this.Finish();
			base.Response.Redirect("/", true);
		}
		if (Text.ToInt32(dataTable.Rows[0]["IsLocked"]) == 1)
		{
			this.Finish();
			base.Response.Redirect("/?err=5", true);
		}
		string sql = string.Concat(new object[]
		{
			"Select count(ID) From [HL_AdsClickRecorde] Where (DateDiff(hh,CreateTime,'",
			DateTime.Now,
			"'))<=24 and ComeIP='",
			userIp,
			"'"
		});
		if (this.conn.ExecuteCount(sql) == 0)
		{
			SiteConfigBll siteConfigBll = new SiteConfigBll();
			int num = Convert.ToInt32(siteConfigBll.GetSiteString("SiteConfigInfo/PromotionScope"));
			if (num > 0)
			{
				UserExpAction userExpAction = new UserExpAction(this.conn);
				if (userExpAction.AddUserExp(this.UID, (long)num, 2, Language.Get("PassPort/PromotionExp"), new Conn[0]))
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HL_User set UserEP=UserEP+",
						num,
						" where UserID=",
						this.UID
					}));
				}
				IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@CreateTime", DbType.DateTime, DateTime.Now),
					this.conn.CreateParameter("@ComeIP", DbType.String, userIp),
					this.conn.CreateParameter("@ComeUrl", DbType.String, value)
				};
				string commandText = string.Concat(new object[]
				{
					"Insert Into [HL_AdsClickRecorde](CreateTime, ComeIP, ComeUrl, AddPoint, UserID) values(@CreateTime, @ComeIP, @ComeUrl, ",
					num,
					", ",
					this.UID,
					")"
				});
				this.conn.Execute(commandText, parameters);
			}
			siteConfigBll.Dispose();
		}
		string text = "<html><head><title></title><script language='javascript'>\n";
		text += "    top.location.href='/';\n";
		text += "</script></head><body></body></html>";
		dataTable.Dispose();
		base.Response.Write(text);
	}
}
